
using System.Web.UI.HtmlControls;
using System;
using System.Configuration;
using System.Drawing;
using System.Data;
using System.Web.UI.WebControls;
using Microsoft.VisualBasic;
using System.Collections;
using System.Web.UI;
using System.Web;


//using com.ddsc.database;
using DDSC.OracleADO;

namespace smasb2b
{
	public class VendorBulletin : System.Web.UI.UserControl
	{
		
#region  Web Form 設計工具產生的程式碼
		
		//此為 Web Form 設計工具所需的呼叫。
		[System.Diagnostics.DebuggerStepThrough()]private void InitializeComponent()
		{
			
		}
		protected System.Web.UI.HtmlControls.HtmlTable bulletin;
		
		//注意: 下列預留位置宣告是 Web Form 設計工具需要的項目。
		//請勿刪除或移動它。
		private System.Object designerPlaceholderDeclaration;
		
		private void Page_Init(System.Object sender, System.EventArgs e)
		{
			//CODEGEN: 此為 Web Form 設計工具所需的方法呼叫
			//請勿使用程式碼編輯器進行修改。
			InitializeComponent();
		}
		
#endregion
		
		private void Page_Load(System.Object sender, System.EventArgs e)
		{
			//在這裡放置使用者程式碼以初始化網頁
			dbAccess dba = new dbAccess();
			BasePage BasePage = new BasePage();
			int rows = 0;
			HtmlTableCell td = default(HtmlTableCell);
			DataSet dsReturn = default(DataSet);
            ArrayList m_arrParam = new ArrayList();

			string SystemDate = DateTime.Now.ToString("yyyyMMdd");
			try
			{
                //Tony : 1.修改SQL語法使用參數，不組字串
                //string SqlCommandText = "select * from b2b_system_notice a,(select notice_no,max(version) as version from b2b_system_notice "
                //    + " where status=\'9\' and start_date<={0} and end_date>{0} and (vendor_kind=\'{1}\' or vendor_kind=\'ALL\') group by notice_no) b "
                //    + " where b.notice_no =  a.notice_no and b.version = a.version ";
                string SqlCommandText = "select * from b2b_system_notice a,(select notice_no,max(version) as version from b2b_system_notice "
                                    + " where status=\'9\' and start_date<=:SystemDate and end_date>:SystemDate and (vendor_kind=:LoginUserVendorKind or vendor_kind=\'ALL\') group by notice_no) b "
                                    + " where b.notice_no =  a.notice_no and b.version = a.version ";

                //Tony : 2.設定動態參數物件
                m_arrParam.Add(dba.GetOracleParam(":SystemDate", SystemDate));
                m_arrParam.Add(dba.GetOracleParam(":LoginUserVendorKind", BasePage.GetLoginUser_Vendor_Kind()));

                //Tony : 3.修改執行方法Overload
                //dsReturn = dba.runExecuteQuery("b2b_system_notice", string.Format(SqlCommandText, SystemDate, BasePage.GetLoginUser_Vendor_Kind()));
                dsReturn = dba.runExecuteQuery("b2b_system_notice", SqlCommandText, m_arrParam);

				//呈現在畫面上
				for (rows = 0; rows <= dsReturn.Tables["b2b_system_notice"].Rows.Count - 1; rows++)
				{
					bulletin.Rows.Add(new HtmlTableRow());
					td = new HtmlTableCell();
					td.Attributes.Add("style", "cursor:hand");
					td.Attributes.Add("onmouseout", "this.className=\'onmouse_out\'");
					td.Attributes.Add("onmouseover", "this.className=\'onmouse_over\'");
					
					td.Attributes.Add("notice_text", System.Convert.ToString(dsReturn.Tables["b2b_system_notice"].Rows[rows]["notice_text"]));
					td.InnerText = "‧" + dsReturn.Tables["b2b_system_notice"].Rows[rows]["start_date"] + " " + dsReturn.Tables["b2b_system_notice"].Rows[rows]["notice_title"];
					bulletin.Rows[bulletin.Rows.Count - 1].Cells.Add(td);
				}
			}
			catch (Exception ex)
			{
				BasePage.showException(this.Page, ex.Message);
			}
			finally
			{
				dsReturn.Dispose();
			}
			
			
			
			
		}
		
	}
}
